﻿// test_12.6.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int Aver(int* p, int n)
{
	int sum = 0;
	int i = 0;
	for (i; i < n; i++)
	{
		sum += *(p + i);
	}
	return sum / n;
}

int Max(int* p, int n)
{
	int i = 0;
	int max = *p;
	for (i; i < n; i++)
	{
		if (*(p + i) > max)
			max = *(p + i);
	}
	return max;
}

int Min(int* p, int n)
{
	int i = 0;
	int min = *p;
	for (i; i < n; i++)
	{
		if (*(p + i) < min)
			min = *(p + i);
	}
	return min;
}

int* Sta(int* p, int n)
{
	int i;
	int a = 0;
	int b = 0;
	int c = 0;
	int d = 0;
	int e = 0;
	for (i = 0; i < n; i++)
	{
		switch (*(p + i) / 10)
		{
		case 10:
			a++;
			break;
		case 9:
			a++;
			break;
		case 8:
			b++;
			break;
		case 7:
			c++;
			break;
		case 6:
			d++;
			break;
		case 5:
		case 4:
		case 3:
		case 2:
		case 1:
		case 0:
			e++;
			break;
		}
	}
	int sta[5] = { a,b,c,d,e };
	int* pc = sta;
	return pc;
}

int main()
{
	int n = 0;
	int i;
	int arr[50] = { 0 };
	printf("输入人数：");
	scanf("%d", &n);
	printf("输入成绩：\n");
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
	}
	int aver = Aver(arr, n);
	int max = Max(arr, n);
	int min = Min(arr, n);
	int* sta = Sta(arr, n);
	printf("平均分：%d\n最高分：%d\n最低分：%d\n", aver, max, min);
	printf("不同分数段的人数为:\n");
	for (i = 0; i < 5; i++)
	{
		printf("%d\n", *(sta + i));
	}
	return 0;
}
